{% extends "base_generic.html" %}
{% block script %}
<script type="text/javascript">
  function generateUrl(singular) {
    var sanitizedName = singular;
    sanitizedName = sanitizedName.replace(/ el /gi, ' ');
    sanitizedName = sanitizedName.replace(/ la /gi, ' ');
    sanitizedName = sanitizedName.replace(/ los /gi, ' ');
    sanitizedName = sanitizedName.replace(/ las /gi, ' ');
    sanitizedName = sanitizedName.replace(/ de /gi, ' ');
    sanitizedName = sanitizedName.replace(/ del /gi, ' ');
    sanitizedName = sanitizedName.replace(/ temporada /gi, ' ');
    sanitizedName = sanitizedName.replace(/--/gi, '-');
    sanitizedName = sanitizedName.replace(/---/gi, '-');
    sanitizedName = sanitizedName.replace(/----/gi, '-');
    sanitizedName = string_to_slug(sanitizedName);
    $("#singularSlug").val(sanitizedName);
  }
  function generateUrlp(plural) {
    var sanitizedName = plural;
    sanitizedName = sanitizedName.replace(/ el /gi, ' ');
    sanitizedName = sanitizedName.replace(/ la /gi, ' ');
    sanitizedName = sanitizedName.replace(/ los /gi, ' ');
    sanitizedName = sanitizedName.replace(/ las /gi, ' ');
    sanitizedName = sanitizedName.replace(/ de /gi, ' ');
    sanitizedName = sanitizedName.replace(/ del /gi, ' ');
    sanitizedName = sanitizedName.replace(/ temporada /gi, ' ');
    sanitizedName = sanitizedName.replace(/--/gi, '-');
    sanitizedName = sanitizedName.replace(/---/gi, '-');
    sanitizedName = sanitizedName.replace(/----/gi, '-');
    sanitizedName = string_to_slug(sanitizedName);
    $("#pluralSlug").val(sanitizedName);
  }
</script>
{% endblock %}
{% block content %}
        <h1>Categoria</h1>
        <form action="/admin/categorias/{{ key }}/save/" method="post">
        
        <div class="line">
          <div class="field">
            <label>Singular:</label>
            <input id="singular" name="singular" type="text" size="50" value="{{ singular }}" onblur="generateUrl(this.value);" />
          </div>
          <div class="field">
            <label>Singular Slug:</label>
            <input id="singularSlug" name="singularSlug" type="text" size="20" value="{{ singularSlug }}" />
          </div>
        </div>
        <div class="line">
          <div class="field">
            <label>Plural:</label>
            <input id="plural" name="plural" type="text" size="50" value="{{ plural }}" onblur="generateUrlp(this.value);" />
          </div>
          <div class="field">
            <label>Plural Slug:</label>
            <input id="pluralSlug" name="pluralSlug" type="text" size="20" value="{{ pluralSlug }}" />
          </div>
        </div>
        <div class="line">
          <div class="field">
            <label>Menu:</label>
            <select name="menu" id="menu">
              <option value="main"{% ifequal menu "main" %} selected="selected"{% endifequal %}>main</option>
              <option value="secondary"{% ifequal menu "secondary" %} selected="selected"{% endifequal %}>secondary</option>
              <option value="manual"{% ifequal menu "manual" %} selected="selected"{% endifequal %}>manual</option>
            </select>
        </div>
        <input type="submit" value="Guardar" id="save" name="save" /><br class="clear" />
      </form>
      <br class="clear" />

{% endblock %}
      